package com.admin.education.models;

import com.admin.education.models.Enum.CategoryType;
import com.admin.education.repositories.Identifiable;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.mapstruct.MappingTarget;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "categorys")
@EntityListeners(AuditingEntityListener.class)
@Data
public class Categorys implements Serializable, Identifiable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name="name")
    @Length(max=64)
    @NotNull
    private String name;
    @Column(name="sort")
    private int sort;
    @NotNull
    private boolean valid;
    @NotNull
    private Date createTime;
    @NotNull
    @Column(name="category_type")
    private CategoryType categoryType;
    @ManyToMany(mappedBy = "categorys")
    @JSONField(serialize=false)
    private List<Templates> templates;
    @ManyToMany(mappedBy = "categorys")
    @JSONField(serialize = false)
    private List<Votes> votes;
    @ManyToMany(mappedBy = "categorys")
    private List<Circles> circles;
}
